package org.jeecg.modules.xindian.reconciliation.entity;

import java.beans.Transient;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.xindian.reconciliation.enums.DeleteFlagEnum;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @Description: 业务员结算比例
 * @Author: jeecg-boot
 * @Date:   2024-04-11
 * @Version: V1.0
 */
@Data
@TableName("salesman_manager_rate")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="salesman_manager_rate对象", description="业务员结算比例")
public class SalesmanManagerRate implements Serializable {
    private static final long serialVersionUID = 1L;

	/**id*/
	@TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "id")
    private java.lang.String id;
	/**创建日期*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "创建日期")
    private java.util.Date createTime;
	/**更新日期*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "更新日期")
    private java.util.Date updateTime;
	/**业务员Id*/
	@Excel(name = "业务员Id", width = 15)
    @ApiModelProperty(value = "业务员Id")
    private java.lang.String salesmanId;
	/**结算单位*/
	@Excel(name = "客户名称", width = 15)
    @ApiModelProperty(value = "客户名称")
    private java.lang.String company;
	/**固定结算比例*/
	@Excel(name = "固定结算比例", width = 15)
    @ApiModelProperty(value = "固定结算比例")
    private java.math.BigDecimal fixRate;
	/**增加特殊比例(json)*/
	@Excel(name = "增加特殊比例(前端忽略)", width = 15)
    @ApiModelProperty(value = "增加特殊比例(json)")
    private java.lang.String otherAreaRate;
	/**是否删除*/
    @Excel(name = "是否删除", width = 15,dicCode = "SC_SFSC")
    @ApiModelProperty(value = "是否删除")
    @Dict(dicCode = "SC_SFSC")
    private DeleteFlagEnum deleteFlag;
    @TableField(exist = false)
    @Excel(name = "增加特殊比例(前端传)", width = 15)
    @ApiModelProperty(value = "增加特殊比例(前端传)")
    private  List<OtherAreaRateConfig> configs;


    public void buildConfigs(){
        if(StringUtils.isNotBlank(otherAreaRate)){
            configs =  JSON.parseArray(otherAreaRate,OtherAreaRateConfig.class);
        }else {
            configs = new ArrayList<>();
        }
    }


    public void buildConfigString(){
        if(CollectionUtils.isNotEmpty(configs)){
            otherAreaRate =  JSON.toJSONString(configs);
        }
    }


    @Data
    public static class  OtherAreaRateConfig{
        @ApiModelProperty("平台代码")
        private List<String> platform;
        @ApiModelProperty("保险公司")
        private String insuranceCompany;
        @ApiModelProperty("比例")
        private BigDecimal rate;
    }
}
